<?php

namespace post\modules\user\controllers;

use post\modules\user\models\User;
use Yii;

use yii\web\Controller;
use post\base\BaseController;

class UserController extends BaseController
{

    //
    public function actionTest()
    {

        echo __DIR__;
    }

    public function actionUser()
    {
        $request_data = get_validate(['user_id']);
        if($request_data == "false") {
            return $this->json_error("参数缺失!");
        }
        $user = User::find()->where(['id' => $request_data['user_id']])
            ->select(['id', 'username'])->one();
        if ($user == null) {
            return $this->json_error("没有这个用户");
        }
        $post_title=$user->posttitle;
        $fans=$user->fans;


        $stars=$user->stars;


        $userInfo=$user->info->toArray();

        $post_count = $user->post;
        $user = $user->toArray();
        $user['postcount'] = $post_count;
        $user['autograph'] = $userInfo['autograph'];
        $user['job'] = $userInfo['job'];
        $user['tou'] = $userInfo['tou'];

        $user['post_title'] = $post_title;
        $user['fans'] = $fans;
        $user['stars'] = $stars;

        return $this->jsonSuccess($user);

    }



}
